package com.isorf.controller;


import com.isorf.pojo.Student;
import com.isorf.service.StudentService;
import com.isorf.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@Api(tags = "学生接口")
@RestController
@RequestMapping("/student")
public class StudentController {
    //调用Service层的方法 获取学生的信息
    @Autowired
    private StudentService studentService;
    @ApiOperation("获得全部学生信息")
    @PostMapping("/getAllStudents")
    public ResponseResult<List<Student>> getAllStudents(){
        List<Student> students = studentService.getAllStudents();
        if(students==null){
            return ResponseResult.failure(ResponseResult.FAILED,"没有学生信息");
        }else {
            return ResponseResult.success(ResponseResult.SUCCESS,"查询成功",students);
        }
    }
}
